/**
 * 
 */
package kr.pe.johnkim.dayve.provider;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteDatabase.CursorFactory;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;

/**
 * @author johnkim
 *
 */
public class DayveCategoryDatabaseHelper extends SQLiteOpenHelper {

	private static final String TAG = DayveCategoryDatabaseHelper.class.getSimpleName();
	
	private static final String DATABASE_NAME = "database_dayve_category.db";
	private static final int DATABASE_VERSION = 10;
	
	public DayveCategoryDatabaseHelper(Context context) {
		super(context,  DATABASE_NAME, null, DATABASE_VERSION);	
		Log.e(TAG, "DayveCategoryDatabaseHelper");
	}

	@Override
	public void onCreate(SQLiteDatabase db) {
		// TODO Auto-generated method stub
		// Category 테이블을 생성 한다.
				db.execSQL(
						" CREATE TABLE if not exists dayve_category" + 
				        " (" +
				        "	  _id					  	  		   INTEGER PRIMARY KEY AUTOINCREMENT" + 
				        "	, id_myhistory_categories 	  		   TEXT" +
				        "   , name	 				  	  		   TEXT" +
				        "   , comment 							   TEXT" +
				        "   , icon_url 							   TEXT" +
				        "   , open_category_yn 		  	  		   TEXT" +
				        "   , favorite_yn			  	  		   TEXT" + 
				        "	, activate_yn			  	  		   TEXT" +
				        "	, modify_date			  	  		   TEXT" +
				        "   , register_date 		  	  		   TEXT" +
				        "   , myhistory_members_id    	  		   TEXT" + 
				        "   , items_count    			  		   TEXT" + 
				        ");"
				        );
	}

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		// TODO Auto-generated method stub
		// Category 테이블을 삭제 한다.
		db.execSQL("DROP TABLE if exists dayve_category");
		
		// 테이블을 새로 생성 한다.
		onCreate(db);
	}

}
